package com.ruoyi.order.mapper;

import com.ruoyi.order.domain.SysOrderOne;
import com.ruoyi.order.domain.SysOrderOneVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * 背调订单Mapper接口
 *
 * @author ruoyi
 * @date 2024-06-24
 */
public interface SysOrderOneMapper
{
    /**
     * 查询背调订单
     *
     * @param id 背调订单主键
     * @return 背调订单
     */
    public SysOrderOne selectSysOrderOneById(Long id);

    /**
     * 查询背调订单列表
     *
     * @param sysOrderOne 背调订单
     * @return 背调订单集合
     */
    public List<SysOrderOne> selectSysOrderOneList(SysOrderOne sysOrderOne);

    /**
     * 新增背调订单
     *
     * @param sysOrderOne 背调订单
     * @return 结果
     */
    public int insertSysOrderOne(SysOrderOne sysOrderOne);

    /**
     * 修改背调订单
     *
     * @param sysOrderOne 背调订单
     * @return 结果
     */
    public int updateSysOrderOne(SysOrderOne sysOrderOne);

    /**
     * 删除背调订单
     *
     * @param id 背调订单主键
     * @return 结果
     */
    public int deleteSysOrderOneById(Long id);

    /**
     * 批量删除背调订单
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteSysOrderOneByIds(Long[] ids);

    void insertBatch(@Param("orderOnes") List<SysOrderOne> orderOnes);

    List<SysOrderOne> selectSysOrderOneByIds(@Param("orderIds") List<Long> orderIds);

    @Select("select * from sys_order where parent_id = #{id}")
    List<SysOrderOne> selectSysOrderOneByParentId(@Param("id") Long id);

    @Select("select id,setmeal_id as setmealId from sys_order where cd_name = #{cdName} and id_number = #{idNumber} and phone = #{phone} and `order_status` = 3 and create_time >#{sevenDay} order by create_time desc")
    List<SysOrderOne> selectSysOrderOneByNameAndCard(@Param("cdName") String cdName, @Param("idNumber") String idNumber, @Param("phone") String phone,@Param("sevenDay") LocalDateTime sevenDay);

    @Update("update sys_order set order_status = #{status} where id = #{orderId}")
    void updateStatusByOrderId(@Param("orderId") Long orderId,@Param("status") Long status);

    List<SysOrderOne> getSysOrderOneList(@Param("sysOrderOne")SysOrderOne sysOrderOne, @Param("beginCreateTime") Date beginCreateTime,@Param("endCreateTime") Date endCreateTime);

    List<SysOrderOneVO> getSysOrderOneVOList(SysOrderOneVO sysOrderOneVO);

    List<SysOrderOneVO> getSysOrderOneVOListOther(@Param("sysOrderOneVO") SysOrderOneVO sysOrderOneVO,@Param("deptId") Long deptId);

    String getUserNameById(Long userId);
}
